import 'package:wanxiang_app/generated/json/base/json_convert_content.dart';
import 'package:wanxiang_app/bean/goods_detail_entity.dart';

GoodsDetailEntity $GoodsDetailEntityFromJson(Map<String, dynamic> json) {
  final GoodsDetailEntity goodsDetailEntity = GoodsDetailEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    goodsDetailEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    goodsDetailEntity.msg = msg;
  }
  final GoodsDetailData? data = jsonConvert.convert<GoodsDetailData>(
      json['data']);
  if (data != null) {
    goodsDetailEntity.data = data;
  }
  return goodsDetailEntity;
}

Map<String, dynamic> $GoodsDetailEntityToJson(GoodsDetailEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data.toJson();
  return data;
}

extension GoodsDetailEntityExtension on GoodsDetailEntity {
  GoodsDetailEntity copyWith({
    int? code,
    String? msg,
    GoodsDetailData? data,
  }) {
    return GoodsDetailEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

GoodsDetailData $GoodsDetailDataFromJson(Map<String, dynamic> json) {
  final GoodsDetailData goodsDetailData = GoodsDetailData();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    goodsDetailData.id = id;
  }
  final int? isSelf = jsonConvert.convert<int>(json['is_self']);
  if (isSelf != null) {
    goodsDetailData.isSelf = isSelf;
  }
  final String? imgUrl = jsonConvert.convert<String>(json['img_url']);
  if (imgUrl != null) {
    goodsDetailData.imgUrl = imgUrl;
  }
  final String? addTime = jsonConvert.convert<String>(json['add_time']);
  if (addTime != null) {
    goodsDetailData.addTime = addTime;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    goodsDetailData.title = title;
  }
  final String? content = jsonConvert.convert<String>(json['content']);
  if (content != null) {
    goodsDetailData.content = content;
  }
  final String? categoryText = jsonConvert.convert<String>(
      json['category_text']);
  if (categoryText != null) {
    goodsDetailData.categoryText = categoryText;
  }
  final String? sellPrice = jsonConvert.convert<String>(json['sell_price']);
  if (sellPrice != null) {
    goodsDetailData.sellPrice = sellPrice;
  }
  final int? isMsg = jsonConvert.convert<int>(json['is_msg']);
  if (isMsg != null) {
    goodsDetailData.isMsg = isMsg;
  }

  final int? isIndulge = jsonConvert.convert<int>(json['is_indulge']);
  if (isIndulge != null) {
    goodsDetailData.isIndulge = isIndulge;
  }
  final bool? isShoucang = jsonConvert.convert<bool>(json['is_shoucang']);
  if (isShoucang != null) {
    goodsDetailData.isShoucang = isShoucang;
  }
  final String? channelName = jsonConvert.convert<String>(json['channel_name']);
  if (channelName != null) {
    goodsDetailData.channelName = channelName;
  }
  final String? isDeductible = jsonConvert.convert<String>(json['is_deductible']);
  if (isDeductible != null) {
    goodsDetailData.isDeductible = isDeductible;
  }

  final String? channelId = jsonConvert.convert<String>(json['channel_id']);
  if (channelId != null) {
    goodsDetailData.channelId = channelId;
  }
  final String? categoryId = jsonConvert.convert<String>(json['category_id']);
  if (categoryId != null) {
    goodsDetailData.categoryId = categoryId;
  }
  final String? phoneNumber = jsonConvert.convert<String>(json['phone_number']);
  if (phoneNumber != null) {
    goodsDetailData.phoneNumber = phoneNumber;
  }
  final String? wxNumber = jsonConvert.convert<String>(json['wx_number']);
  if (wxNumber != null) {
    goodsDetailData.wxNumber = wxNumber;
  }
  final String? qqNumber = jsonConvert.convert<String>(json['qq_number']);
  if (qqNumber != null) {
    goodsDetailData.qqNumber = qqNumber;
  }
  final String? accountSource = jsonConvert.convert<String>(
      json['account_source']);
  if (accountSource != null) {
    goodsDetailData.accountSource = accountSource;
  }
  final String? isBargain = jsonConvert.convert<String>(json['is_bargain']);
  if (isBargain != null) {
    goodsDetailData.isBargain = isBargain;
  }
  final String? gameAccount = jsonConvert.convert<String>(json['game_account']);
  if (gameAccount != null) {
    goodsDetailData.gameAccount = gameAccount;
  }
  final String? fields = jsonConvert.convert<String>(json['fields']);
  if (fields != null) {
    goodsDetailData.fields = fields;
  }
  final List<GoodsDetailDataAlbums>? albums = (json['albums'] as List<dynamic>?)
      ?.map(
          (e) =>
      jsonConvert.convert<GoodsDetailDataAlbums>(e) as GoodsDetailDataAlbums)
      .toList();
  if (albums != null) {
    goodsDetailData.albums = albums;
  }
  final String? roleText = jsonConvert.convert<String>(json['role_text']);
  if (roleText != null) {
    goodsDetailData.roleText = roleText;
  }
  final String? goodGuid = jsonConvert.convert<String>(json['good_guid']);
  if (goodGuid != null) {
    goodsDetailData.goodGuid = goodGuid;
  }
  final String? goodName = jsonConvert.convert<String>(json['good_name']);
  if (goodName != null) {
    goodsDetailData.goodName = goodName;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    goodsDetailData.status = status;
  }
  final String? sxPrice = jsonConvert.convert<String>(json['sx_price']);
  if (sxPrice != null) {
    goodsDetailData.sxPrice = sxPrice;
  }
  return goodsDetailData;
}

Map<String, dynamic> $GoodsDetailDataToJson(GoodsDetailData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['is_self'] = entity.isSelf;
  data['img_url'] = entity.imgUrl;
  data['add_time'] = entity.addTime;
  data['title'] = entity.title;
  data['content'] = entity.content;
  data['category_text'] = entity.categoryText;
  data['sell_price'] = entity.sellPrice;
  data['is_msg'] = entity.isMsg;
  data['is_deductible'] = entity.isDeductible;
  data['is_indulge'] = entity.isIndulge;
  data['is_shoucang'] = entity.isShoucang;
  data['channel_name'] = entity.channelName;
  data['channel_id'] = entity.channelId;
  data['category_id'] = entity.categoryId;
  data['phone_number'] = entity.phoneNumber;
  data['wx_number'] = entity.wxNumber;
  data['qq_number'] = entity.qqNumber;
  data['account_source'] = entity.accountSource;
  data['is_bargain'] = entity.isBargain;
  data['game_account'] = entity.gameAccount;
  data['fields'] = entity.fields;
  data['albums'] = entity.albums.map((v) => v.toJson()).toList();
  data['role_text'] = entity.roleText;
  data['good_guid'] = entity.goodGuid;
  data['good_name'] = entity.goodName;
  data['status'] = entity.status;
  data['sx_price'] = entity.sxPrice;
  return data;
}

extension GoodsDetailDataExtension on GoodsDetailData {
  GoodsDetailData copyWith({
    int? id,
    int? isSelf,
    String? imgUrl,
    String? addTime,
    String? title,
    String? content,
    String? categoryText,
    String? sellPrice,
    int? isMsg,
    int? isIndulge,
    bool? isShoucang,
    String? channelName,
    String? channelId,
    String? categoryId,
    String? isDeductible,
    String? phoneNumber,
    String? wxNumber,
    String? qqNumber,
    String? accountSource,
    String? isBargain,
    String? gameAccount,
    String? fields,
    List<GoodsDetailDataAlbums>? albums,
    String? roleText,
    String? goodGuid,
    String? goodName,
    int? status,
    String? sxPrice,
  }) {
    return GoodsDetailData()
      ..id = id ?? this.id
      ..isSelf = isSelf ?? this.isSelf
      ..imgUrl = imgUrl ?? this.imgUrl
      ..addTime = addTime ?? this.addTime
      ..title = title ?? this.title
      ..content = content ?? this.content
      ..isDeductible = isDeductible ?? this.isDeductible
      ..categoryText = categoryText ?? this.categoryText
      ..sellPrice = sellPrice ?? this.sellPrice
      ..isMsg = isMsg ?? this.isMsg
      ..isIndulge = isIndulge ?? this.isIndulge
      ..isShoucang = isShoucang ?? this.isShoucang
      ..channelName = channelName ?? this.channelName
      ..channelId = channelId ?? this.channelId
      ..categoryId = categoryId ?? this.categoryId
      ..phoneNumber = phoneNumber ?? this.phoneNumber
      ..wxNumber = wxNumber ?? this.wxNumber
      ..qqNumber = qqNumber ?? this.qqNumber
      ..accountSource = accountSource ?? this.accountSource
      ..isBargain = isBargain ?? this.isBargain
      ..gameAccount = gameAccount ?? this.gameAccount
      ..fields = fields ?? this.fields
      ..albums = albums ?? this.albums
      ..roleText = roleText ?? this.roleText
      ..goodGuid = goodGuid ?? this.goodGuid
      ..goodName = goodName ?? this.goodName
      ..status = status ?? this.status
      ..sxPrice = sxPrice ?? this.sxPrice;
  }
}

GoodsDetailDataAlbums $GoodsDetailDataAlbumsFromJson(
    Map<String, dynamic> json) {
  final GoodsDetailDataAlbums goodsDetailDataAlbums = GoodsDetailDataAlbums();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    goodsDetailDataAlbums.id = id;
  }
  final String? originalPath = jsonConvert.convert<String>(
      json['original_path']);
  if (originalPath != null) {
    goodsDetailDataAlbums.originalPath = originalPath;
  }
  return goodsDetailDataAlbums;
}

Map<String, dynamic> $GoodsDetailDataAlbumsToJson(
    GoodsDetailDataAlbums entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['original_path'] = entity.originalPath;
  return data;
}

extension GoodsDetailDataAlbumsExtension on GoodsDetailDataAlbums {
  GoodsDetailDataAlbums copyWith({
    int? id,
    String? originalPath,
  }) {
    return GoodsDetailDataAlbums()
      ..id = id ?? this.id
      ..originalPath = originalPath ?? this.originalPath;
  }
}